//
//  GMResultCell.m
//  Teecloud
//
//  Created by 小熊 on 2018/11/14.
//  Copyright © 2018年 小志. All rights reserved.
//

#import "GMResultCell.h"
@interface GMResultCell()
@property (weak, nonatomic) IBOutlet UIButton *resltBtn;

@end
@implementation GMResultCell

- (void)awakeFromNib {
    [super awakeFromNib];
     self.resltBtn.layer.cornerRadius =15;
}
-(void)setModel:(GMAnswerCards *)model{
    _model = model;
    [self.resltBtn setTitle:model.SortNo forState:UIControlStateNormal];
    if ([model.tepName isEqualToString:@"随堂练习"]) {
        [self.resltBtn setTitleColor:kWhiteColor forState:UIControlStateNormal];
        if (model.IsCorrect) {
            self.resltBtn.backgroundColor = [UIColor colorWithHexString:@"00B432"];
        }else{
            self.resltBtn.backgroundColor = kRedColor;
        }
    }else{
        if (kIsEmptyString(model.Answer)) {
            [self.resltBtn setTitleColor:kDarkGrayColor forState:UIControlStateNormal];
            self.resltBtn.backgroundColor = kWhiteColor;
            self.resltBtn.layer.borderWidth =1.0;
            self.resltBtn.layer.borderColor =kDarkGrayColor.CGColor;
        }else{
            [self.resltBtn setTitleColor:kWhiteColor forState:UIControlStateNormal];
            if (model.IsCorrect) {
                self.resltBtn.backgroundColor = [UIColor colorWithHexString:@"00B432"];
            }else{
                self.resltBtn.backgroundColor = kRedColor;
            }
        }
    }
   
}
-(void)setItemModel:(GMAnswerItem *)itemModel{
    _itemModel = itemModel;
    [self.resltBtn setTitle:itemModel.SortNo forState:UIControlStateNormal];
    if (kIsEmptyString(itemModel.Answer)) {
        [self.resltBtn setTitleColor:kDarkGrayColor forState:UIControlStateNormal];
        self.resltBtn.backgroundColor = kWhiteColor;
        self.resltBtn.layer.borderWidth =1.0;
        self.resltBtn.layer.borderColor =kDarkGrayColor.CGColor;
    }else{
        if (!kIsEmptyString(itemModel.type)) {
            //如果不为空就是试卷答题卡
            [self.resltBtn setTitleColor:kWhiteColor forState:UIControlStateNormal];
            self.resltBtn.backgroundColor = [UIColor colorWithHexString:@"007AFF"];
        }else{
            [self.resltBtn setTitleColor:kWhiteColor forState:UIControlStateNormal];
            if (itemModel.IsCorrect) {
                self.resltBtn.backgroundColor = [UIColor colorWithHexString:@"00B432"];
            }else{
                self.resltBtn.backgroundColor = kRedColor;
            }
        }
    }
}
-(void)setSubModel:(GMSubjectsModel *)subModel{
    _subModel = subModel;
    [self.resltBtn setTitle:subModel.SortNo forState:UIControlStateNormal];
    if (kIsEmptyString(subModel.Answer)) {
        [self.resltBtn setTitleColor:kDarkGrayColor forState:UIControlStateNormal];
        self.resltBtn.backgroundColor = kWhiteColor;
        self.resltBtn.layer.borderWidth =1.0;
        self.resltBtn.layer.borderColor =kDarkGrayColor.CGColor;
    }else{
        [self.resltBtn setTitleColor:kWhiteColor forState:UIControlStateNormal];
        self.resltBtn.backgroundColor = [UIColor colorWithHexString:@"007AFF"];
    }
}
@end
